package org.anderground.editor.gui.view;

import java.awt.Rectangle;
import java.util.Observer;

import javax.swing.JPanel;

import org.anderground.core.model.Station;
import org.anderground.editor.model.EditorModel;

@SuppressWarnings("serial")
public abstract class MetroView extends JPanel implements Observer {

	public abstract void afterPanelInit();

	public static Rectangle getMapBounds() {

		float maxX = Float.NEGATIVE_INFINITY, minX = Float.POSITIVE_INFINITY, maxY = Float.NEGATIVE_INFINITY, minY = Float.POSITIVE_INFINITY;
		for (Station station : EditorModel.getInstance().getData()
				.getStations()) {
			maxX = Math.max(station.getPosition().getX(), maxX);
			maxY = Math.max(station.getPosition().getY(), maxY);
			minX = Math.min(station.getPosition().getX(), minX);
			minY = Math.min(station.getPosition().getY(), minY);
		}
		return new Rectangle((int) minX, (int) minY, (int) (maxX - minX),
				(int) (maxY - minY));

	}

}
